package controllers;

import play.*;
import play.data.validation.Required;
import play.data.validation.Valid;
import play.libs.Crypto;
import play.mvc.*;
import utils.Constants;
import utils.Secure;

import java.util.*;

import models.*;

public class Comments extends Application {
	
	public static void edit(Long id){
		Comment comment = Comment.findById(id);
		render(comment);
	}
	
	public static void save(Comment comment,@Required Long storyId,@Required Long postUserId){
		comment.story = Story.findById(storyId);
		comment.postUser = User.findById(postUserId);
		comment.save();
	}
	
	public static void list(Long storyId){
		Story story = Story.findById(storyId);
		render(story.comments);
	}
	
	public static void delete(Long id){
		Comment.delete("byId", id);
	}
}